package com.cby.operation.common.util

import android.os.Handler
import android.os.Looper

/**
 * @description: HandlerUtil
 *
 * @author ChenBaoYang
 * @date 6/1/21 11:26
 */
object HandlerUtils {

    private val mainHandler = Handler(Looper.getMainLooper())

    fun runOnMainThread(task: Runnable) {
        mainHandler.post(task)
    }

    fun runOnMainThread(task: Runnable, delay: Int) {
        mainHandler.postDelayed(task, delay.toLong())
    }

    val isMainThread: Boolean
        get() = Looper.getMainLooper().thread === Thread.currentThread()
}